<?php
/**
 * Created by 784855684@qq.com.
 * Link: https://github.com/lichtung/wshore
 * User: linzh
 * Date: 6/25/17
 * Time: 5:14 PM
 */
declare(strict_types=1);


namespace wshore\helper\traits;

/**
 * Trait Magic 模式方法访问
 * @package wshore\helper\traits
 */
trait Magic
{

    private $_properties = [];

    public function __set(string $var, $val)
    {
        $this->_properties[$var] = $val;
    }

    public function __get(string $var)
    {
        return $this->_properties[$var]??null;
    }

    public function __toString(): string
    {
        return json_encode($this->_properties);
    }
}